﻿using System.Security.Claims;
using Microsoft.AspNetCore.SignalR;

namespace WebApplication1;

public class MongoUserIdProvider : IUserIdProvider
{
    public string? GetUserId(HubConnectionContext connection)
    {
        // 从 JWT 中提取你自定义的 Claim
        return connection.User?.FindFirst(ClaimTypes.NameIdentifier)?.Value;
    }
}